﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;

namespace HackingSilverlightCodeBrowser
{
    public class HSLCollection
    {
        public ObservableCollection<HSLItem> Collection = new ObservableCollection<HSLItem>();

        public HSLCollection()
        {
            Collection.Add(new HSLItem("Animating Cloud Panel", "panel~animation~animate~animatingpanelbase~animatingcloudpanel~csharp~control~crossfader", "public class AnimatingCloudPanel : AnimatingPanelBase{private bool MyFirstTime = true;private int CloudBehavior = 1;private DispatcherTimer MyRollTimer;private List<int> ItemZIndex = new List<int>();private List<double> Positions = new List<double>();private List<double> PositionsX = new List<double>();private List<double> TransformThis = new List<double>();private bool IsInit = false;private double ThisMiddle = 300;public double ChildOffsetWidth = 280;public double PublicWidth = 600;public double PublicHeight = 600;public double LayoutTop = 100;public AnimatingCloudPanel(){AnimationCompleted += new RoutedEventHandler(RandomPanel_AnimationCompleted);this.Loaded += new RoutedEventHandler(AnimatingCloudPanel_Loaded);}void AnimatingCloudPanel_Loaded(object sender, RoutedEventArgs e){ if (ChildOffsetWidth == 0){ChildOffsetWidth = 1;}}void RandomPanel_AnimationCompleted(object sender, RoutedEventArgs e){MyFirstTime = true;MyRollTimer = new DispatcherTimer();MyRollTimer.Interval = TimeSpan.FromMilliseconds(10000);MyRollTimer.Tick += new EventHandler(MyRollTimerTick);MyRollTimer.Start();}public void RoleBack(){List<int> NewItemZIndex = new List<int>();List<double> NewPositions = new List<double>();List<double> NewPositionsX = new List<double>();List<double> NewTransformThis = new List<double>();for (int x = 0; x < this.Children.Count - 1; x++){NewItemZIndex.Add(ItemZIndex[x + 1]);NewPositions.Add(Positions[x + 1]);NewPositionsX.Add(PositionsX[x + 1]);NewTransformThis.Add(TransformThis[x + 1]);}NewItemZIndex.Add(ItemZIndex[0]);NewPositions.Add(Positions[0]);NewPositionsX.Add(PositionsX[0]);NewTransformThis.Add(TransformThis[0]);ItemZIndex = NewItemZIndex;Positions = NewPositions;PositionsX = NewPositionsX;TransformThis = NewTransformThis;InvalidateArrange();}public void RoleForward(){List<int> NewItemZIndex = new List<int>();List<double> NewPositions = new List<double>();List<double> NewPositionsX = new List<double>();List<double> NewTransformThis = new List<double>();NewItemZIndex.Add(ItemZIndex[this.Children.Count - 1]);NewPositions.Add(Positions[this.Children.Count - 1]);NewPositionsX.Add(PositionsX[this.Children.Count - 1]);NewTransformThis.Add(TransformThis[this.Children.Count - 1]);for (int x = 0; x < this.Children.Count - 1; x++){NewItemZIndex.Add(ItemZIndex[x]);NewPositions.Add(Positions[x]);NewPositionsX.Add(PositionsX[x]);NewTransformThis.Add(TransformThis[x]);}ItemZIndex = NewItemZIndex;Positions = NewPositions;PositionsX = NewPositionsX;TransformThis = NewTransformThis;InvalidateArrange();}void MyRollTimerTick(object sender, EventArgs e){ MyRollTimer.Stop();}public void InitCollections(){ItemZIndex.Clear(); Positions.Clear();PositionsX.Clear();TransformThis.Clear();int NewZIndex = 99;double NewOpacity = 1;double NewTransformThis = 1;int MaxVisable = 5;MaxVisable = (this.Children.Count < MaxVisable) ? this.Children.Count : MaxVisable;for (int x = 0; x < this.Children.Count; x++){if (x > 0){NewZIndex--;NewOpacity = ((NewOpacity - .2) < 0) ? 0 : (NewOpacity - .4);NewTransformThis = NewTransformThis - (NewTransformThis * .9);if (x < MaxVisable){if ((x % 2) == 0){PositionsX.Add((ThisMiddle / 2) - ChildOffsetWidth);}else{PositionsX.Add(ThisMiddle);}}else{PositionsX.Add(ThisMiddle - ChildOffsetWidth);}}else{PositionsX.Add(ThisMiddle - ChildOffsetWidth);}ItemZIndex.Add(NewZIndex); TransformThis.Add(NewOpacity);if (x < MaxVisable){if (x == 0){Positions.Add(LayoutTop);}else{Positions.Add(LayoutTop / 2);}}else{Positions.Add(-1000);}}if (CloudBehavior == 1 && ItemZIndex.Count > 2){int temp = ItemZIndex[0];ItemZIndex[0] = ItemZIndex[1];ItemZIndex[1] = temp;double temp3 = Positions[0];Positions[0] = Positions[1];Positions[1] = temp3;double temp4 = PositionsX[0];PositionsX[0] = PositionsX[1];PositionsX[1] = temp4;double temp5 = TransformThis[0];TransformThis[0] = TransformThis[1];TransformThis[1] = temp5;}}protected override Size MeasureOverride(Size availableSize){if (!IsInit){IsInit = true;ThisMiddle = availableSize.Width / 2;PublicWidth = (availableSize.Width < 600) ? 600 : availableSize.Width;PublicWidth = (PublicWidth > 1000) ? PublicWidth - 100 : PublicWidth;PublicHeight = availableSize.Height;InitCollections();}for (int x = 0; x < this.Children.Count; x++){this.Children[x].Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));}return new Size();}protected override Size ArrangeOverride(Size FinalSize){int x = 0;foreach (UIElement e in this.Children){SetElementLocation(e, new Rect(PositionsX[x], Positions[x], this.DesiredSize.Width, e.DesiredSize.Height));e.SetValue(Canvas.ZIndexProperty, ItemZIndex[x]);if (e.GetType().ToString() == \"HackingSilverlightLibrary.ContentControl\"){((ContentControl)e).SetSizeTransform(TransformThis[x]);}x++;}if (MyFirstTime && this.Children.Count > 0){MyFirstTime = false;this.InvalidateMeasure();}return FinalSize;}}"));
            Collection.Add(new HSLItem("Animating Multi Panel", "panel~animation~animate~animatingmultipanel~animatingpanelbase~csharp~control", "public class AnimatingMultiPanel : AnimatingPanelBase { private bool MyFirstTime = true;List<double> XList = new List<double>();List<double> YList = new List<double>();double Radius = 0;public string Mode { get  {  return (string)GetValue(ModeProperty);  } set  {  SetValue(ModeProperty, value);  }  } public readonly DependencyProperty ModeProperty = DependencyProperty.Register(\"Mode\", typeof(string), typeof(AnimatingPanelBase), null);public AnimatingMultiPanel() { AnimationCompleted += new RoutedEventHandler(AnimatingSwitchPanel_AnimationCompleted);if (Mode != \"Wrap\" || Mode != \"Radial\" || Mode != \"Stack\" || Mode != \"Random\") { Mode = \"Wrap\"; }  } void AnimatingSwitchPanel_AnimationCompleted(object sender, RoutedEventArgs e) {  } protected override Size MeasureOverride(Size availableSize) { for (int x = 0; x < this.Children.Count; x++) { this.Children[x].Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); } return new Size(); } protected void GetListOfPoints(int pointCount, double Width) { double x = Width / 2;Radius = x;double y = 0;double theta = (2 * Math.PI) / pointCount;for (int i = 0; i < pointCount; i++) { if (i > 0) { x = (Radius * (Math.Cos((i) * theta)));y = (Radius * (Math.Sin((i) * theta))); } XList.Add(x + Radius);YList.Add(y + Radius); }  } protected override Size ArrangeOverride(Size FinalSize) { switch (Mode) { case \"Random\":FinalSize = ArrangeRandom(FinalSize);break;case \"Radial\":FinalSize = ArrangeRadial(FinalSize);break;case \"Stack\":FinalSize = ArrangeStack(FinalSize);break;default:FinalSize = ArrangeWrap(FinalSize);break; } return FinalSize; } private Size ArrangeStack(Size FinalSize) { Double top = 0;foreach (UIElement e in this.Children) { if (MyFirstTime) { SetElementLocation(e, new Rect(0, 1500, this.DesiredSize.Width, e.DesiredSize.Height), false); } else { SetElementLocation(e, new Rect(0, top, this.DesiredSize.Width, e.DesiredSize.Height)); } top += e.DesiredSize.Height; } if (MyFirstTime && this.Children.Count > 0) { MyFirstTime = false;this.InvalidateMeasure(); } return FinalSize; } private Size ArrangeRadial(Size FinalSize) { double Width = 0;double Height = 0;GetListOfPoints(this.Children.Count, this.Width);int Count = 0;foreach (UIElement element in this.Children) { Width = element.DesiredSize.Width;Height = element.DesiredSize.Height;if (MyFirstTime) { SetElementLocation(element, new Rect(XList[Count], 1500, Width, Height), false); } else { SetElementLocation(element, new Rect(XList[Count], YList[Count], Width, Height)); } Count++; } if (MyFirstTime && this.Children.Count > 0) { MyFirstTime = false;this.InvalidateMeasure(); } return FinalSize; } private Size ArrangeRandom(Size FinalSize) { double Width = 0;double Height = 0;Random ThisNum = new Random();foreach (UIElement element in this.Children) { Width = element.DesiredSize.Width;Height = element.DesiredSize.Height;double NewX = double.Parse(ThisNum.Next(int.Parse(this.Width.ToString())).ToString());double NewY = double.Parse(ThisNum.Next(int.Parse(this.Height.ToString())).ToString());if (MyFirstTime) { SetElementLocation(element, new Rect(NewX, 1500, Width, Height), false); } else { SetElementLocation(element, new Rect(NewX, NewY, Width, Height)); }  } if (MyFirstTime && this.Children.Count > 0) { MyFirstTime = false;this.InvalidateMeasure(); } return FinalSize; } private Size ArrangeWrap(Size FinalSize) { double Top = 0;double Left = 0;double Width = 0;double Height = 0;double NextTop = 0;foreach (UIElement element in this.Children) { Width = element.DesiredSize.Width;Height = element.DesiredSize.Height;if ((Left + Width) > FinalSize.Width) { Left = 0;Top = NextTop;NextTop = 0; } if (MyFirstTime) { SetElementLocation(element, new Rect(Left, 1500, Width, Height), false); } else { SetElementLocation(element, new Rect(Left, Top, Width, Height), true); } Left = Left + Width;NextTop = Math.Max(NextTop, Top + Height); } if (MyFirstTime && this.Children.Count > 0) { MyFirstTime = false;this.InvalidateMeasure(); } return FinalSize; }  } "));
            Collection.Add(new HSLItem("Application Xaml", "application~xaml~app.xaml", "<Application xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" x:Class=\"SUGWTK.App\" ><Application.Resources></Application.Resources></Application>"));
            Collection.Add(new HSLItem("Asynchronous Image Loading", "csharp~asynchronous~image~loading~xaml~url", "WebClient client = new WebClient(); client.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);if (ImagePath.IndexOf(\"http\") < 0) {string URL = System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri;ImagePath = URL.Substring(0, URL.LastIndexOf('/')) + \"/\" + ImagePath;} client.OpenReadAsync(new Uri(ImagePath, UriKind.RelativeOrAbsolute), ImagePath);void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { BitmapImage ImageToLoad = new BitmapImage();ImageToLoad.SetSource(e.Result as Stream);TargetImage.Source = ImageToLoad;}"));
            Collection.Add(new HSLItem("Behavior For Blend", "behavior~command~csharp~color~brush~setcolor~control~blend", "System.Windows.Interactivity.dll using System.Windows.Interactivity; public class SomeBehavior : TargetedTriggerAction<FrameworkElement> { Shape TargetElementItem1; Brush Color1; Brush Color2 = new SolidColorBrush(Color.FromArgb(0,0,0,0)); protected override void Invoke(object parameter) { TargetElementItem1 = (Shape)(this.AssociatedObject); Color1 = (Brush)(TargetElementItem1.Fill); TargetElementItem1.MouseLeftButtonDown += new MouseButtonEventHandler(TargetElementItem1_MouseLeftButtonDown); TargetElementItem1.MouseLeftButtonUp += new MouseButtonEventHandler(TargetElementItem1_MouseLeftButtonUp); } void TargetElementItem1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { TargetElementItem1.Fill = Color1; } void TargetElementItem1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { TargetElementItem1.Fill = Color2; }}"));
            Collection.Add(new HSLItem("BitMap Effects", "bitmap~effect~pixelshader~xaml~ps~csharp~image", "<Image Source=\"../Img/cover.png\" Grid.Column=\"1\" ><Image.Effect><hsl:Shader x:Name=\"TargetShader\" SetEffect=\"Ripples\" /></Image.Effect></Image>public class Shader : ShaderEffect{public Shader() { }public string SetEffect{get { return (string)GetValue(SetEffectProperty); }set { SetValue(SetEffectProperty, value); }}public readonly DependencyProperty SetEffectProperty = DependencyProperty.Register(\"SetEffect\", typeof(string), typeof(Shader), new PropertyMetadata(new PropertyChangedCallback(OnSetEffectChanged)));private static void OnSetEffectChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e){ShaderEffect ThisElement = DpObj as ShaderEffect;if (ThisElement != null){((Shader)(ThisElement)).PixelShader = new PixelShader(){UriSource = new Uri(\"HackingSilverlightLibrary;component/PixelShaders/\" + ((Shader)(ThisElement)).SetEffect + \".ps\", UriKind.RelativeOrAbsolute)}; }}}// PIXEL SHADER CODE sampler2D input : register(S0);float4 main(float2 uv : TEXCOORD) : COLOR{uv.y = uv.y  + (sin(uv.y*100)*0.03);return tex2D( input , uv.xy);}"));
            Collection.Add(new HSLItem("Border", "border~xaml~control", "<Border BorderThickness=\"20\" Background=\"white\" BorderBrush=\"Green\" Padding=\"3\" CornerRadius=\"10\" ><TextBlock Text=\"Hello World\"></TextBlock></Border>"));
            Collection.Add(new HSLItem("Button", "button~xaml~control", "<Button x:Name=\"MyButton\" Height=\"20\" Content=\"Change Layout\" Click=\"MyButton_Click\" />private void MyButton_Click(object sender, RoutedEventArgs e) { }"));
            Collection.Add(new HSLItem("Canvas", "canvas~xaml~layout", "<Canvas Name=\"CanvasElement\" Height=\"100\" Width=\"100\" Canvas.Left=\"50\" Canvas.Top=\"50\" Background=\"#728f4a\" Opacity=\"0.6\" Canvas.ZIndex=\"2\" ></Canvas>"));
            Collection.Add(new HSLItem("CheckBox", "xaml~checkbox~control", "<CheckBox x:Name=\"MyCheckBox\" Checked=\"MyCheckBox_Checked\" ToolTip=\"My first checkbox\" Unchecked=\"MyCheckBox_Unchecked\" />"));
            Collection.Add(new HSLItem("Clip", "xaml~clip~geometry~clippingregion", "<Polygon.Clip><RectangleGeometry Rect=\"0, 0, 50, 50\"/></Polygon.Clip>"));
            Collection.Add(new HSLItem("ClientAccessPolicy.xml", "clientaccess~policy~clientaccesspolicy~clientaccesspolicy.xml~xml", "<?xml version=\"1.0\" encoding=\"utf-8\"?><access-policy><cross-domain-access><policy><allow-from><domain uri=\"*\"/></allow-from><grant-to><resource path=\"/\" include-subpaths=\"true\"/></grant-to></policy></cross-domain-access></access-policy>"));
            Collection.Add(new HSLItem("ColorAnimation", "xaml~clip~color~animation~storyboard", "<ColorAnimation Storyboard.TargetName=\"PolygonElement\" Storyboard.TargetProperty=\"(Fill).(Color)\" From=\"#3c5f0c\" To=\"#728f4a\" Duration=\"0:0:5\" />"));
            Collection.Add(new HSLItem("Composite Transform", "compositetransform~transform~xaml", "<CompositeTransform Rotation=\"-48.814\" SkewX=\"-3\" SkewY=\"-1\" ScaleY=\"-1.1\" ScaleX=\"1.25\" TranslateX=\"11\" TranslateY=\"8\"/>")); 
            Collection.Add(new HSLItem("CrossDomain.xml", "crossdomain~crossdomain.xml~xml", "<?xml version=\"1.0\"?><!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\"><cross-domain-policy><allow-access-from domain=\"*\" /></cross-domain-policy>"));
            Collection.Add(new HSLItem("Custom Animating Panel Base", "animatingpanelbase~panel~class~abstract~csharp~timer~animation~control~robby", "public abstract class AnimatingPanelBase : Panel {private DispatcherTimer timer;private Dictionary<UIElement, ElementState> _states;double _animatingCount;bool _isTimerStarted;public Dictionary<UIElement, ElementState> States{get { return _states; }}public AnimatingPanelBase(){ _states = new Dictionary<UIElement, ElementState>();this.Force = 1.0;this.Resistance = 0.25;this.Milliseconds = 30;this.SnapPrecision = 2.0;this.Randomness = 0.5;this.IsAnimationEnabled = true;} #region Dependency Properties #region Force (DependencyProperty) public double Force{get { return (double)GetValue(ForceProperty); }set { SetValue(ForceProperty, value); }}public readonly DependencyProperty ForceProperty = DependencyProperty.Register(\"Force\", typeof(double), typeof(AnimatingPanelBase), null); #endregion #region Resistance (DependencyProperty) public double Resistance{get { return (double)GetValue(ResistanceProperty); }set { SetValue(ResistanceProperty, value); } } public readonly DependencyProperty ResistanceProperty = DependencyProperty.Register(\"Resistance\", typeof(double), typeof(AnimatingPanelBase), null); #endregion #region Milliseconds (DependencyProperty) public double Milliseconds { get { return (double)GetValue(MillisecondsProperty); } set { SetValue(MillisecondsProperty, value); } } public readonly DependencyProperty MillisecondsProperty = DependencyProperty.Register(\"Milliseconds\", typeof(double), typeof(AnimatingPanelBase), null); #endregion #region SnapPrecision (DependencyProperty) public double SnapPrecision{get { return (double)GetValue(SnapPrecisionProperty); }set { SetValue(SnapPrecisionProperty, value); }} public readonly DependencyProperty SnapPrecisionProperty = DependencyProperty.Register(\"SnapPrecision\", typeof(double), typeof(AnimatingPanelBase), null); #endregion #region Randomness (DependencyProperty) public double Randomness{get { return (double)GetValue(RandomnessProperty); }set { SetValue(RandomnessProperty, value); }} public readonly DependencyProperty RandomnessProperty = DependencyProperty.Register(\"Randomness\", typeof(double), typeof(AnimatingPanelBase), null); #endregion #region IsAnimationEnabled (DependencyProperty) public bool IsAnimationEnabled{get { return (bool)GetValue(IsAnimationEnabledProperty); }set { SetValue(IsAnimationEnabledProperty, value); }} public readonly DependencyProperty IsAnimationEnabledProperty = DependencyProperty.Register(\"IsAnimationEnabled\", typeof(bool), typeof(AnimatingPanelBase), null); #endregion #endregion public event RoutedEventHandler AnimationCompleted;protected void SetElementLocation(UIElement element, Rect finalRect, bool isAnimated){ ElementState state = null;if (States.ContainsKey(element)){state = States[element];}else{state = new ElementState(finalRect, this.Randomness);States.Add(element, state);} if (isAnimated && IsAnimationEnabled){if (!state.NeedsArrange){state.NeedsArrange = true;_animatingCount++;}state.TargetRect = finalRect;StartTimer();}else{element.Arrange(finalRect);state.CurrentRect = finalRect;if (state.NeedsArrange){state.NeedsArrange = false;_animatingCount--;}}}protected void SetElementLocation(UIElement element, Rect finalRect){SetElementLocation(element, finalRect, true);}private void RaiseAnimationCompleted(){StopTimer();if (AnimationCompleted != null){AnimationCompleted(this, new RoutedEventArgs());}}private void StartTimer(){if (timer == null){timer = new DispatcherTimer();timer.Interval = TimeSpan.FromMilliseconds((int)1000 / 60); timer.Tick += new EventHandler(timer_Tick);}if (!_isTimerStarted){timer.Start();_isTimerStarted = true;}}void timer_Tick(object sender, EventArgs e){UpdateElementLocations();}private void StopTimer(){if (timer != null){timer.Stop();_isTimerStarted = false;}}private void UpdateElementLocations(){ElementState state;foreach (UIElement element in Children){if (States.ContainsKey(element)){state = States[element];if (UpdateElementLocation(element, state)){element.Arrange(state.CurrentRect);}}}}private bool UpdateElementLocation(UIElement child, ElementState state){if (state == null){return false;}else if (state.NeedsArrange){ double force = this.Force;double resistance = this.Resistance;double seconds = 1.0 / this.Milliseconds;Point newCurrentLocation;Vector newLocationVelocity;bool locationChanged = RecalculateCurrentPoint(ToPoint(state.CurrentRect), ToPoint(state.TargetRect), state.LocationVelocity,seconds, resistance, force * state.AttractionMultiplier,out newCurrentLocation, out newLocationVelocity);Point newCurrentSize;Vector newSizeVelocity;bool sizeChanged = RecalculateCurrentPoint(GetPointFromSize(ToSize(state.CurrentRect)), GetPointFromSize(ToSize(state.TargetRect)),state.SizeVelocity,seconds, resistance, force * state.AttractionMultiplier,out newCurrentSize, out newSizeVelocity);if (locationChanged || sizeChanged){state.CurrentRect.X = newCurrentLocation.X;state.CurrentRect.Y = newCurrentLocation.Y;state.LocationVelocity = newLocationVelocity;Size newSizeFromPoint = GetSizeFromPoint(newCurrentSize);double newWidth = Math.Max(newSizeFromPoint.Width, child.DesiredSize.Width);double newHeight = Math.Max(newSizeFromPoint.Height, child.DesiredSize.Height);state.CurrentRect.Width = newWidth;state.CurrentRect.Height = newHeight;state.SizeVelocity = newSizeVelocity;return true;}else{state.NeedsArrange = false;_animatingCount--;if (_animatingCount == 0){this.RaiseAnimationCompleted();}return false;}}return false;}private static Point ToPoint(Rect r){return new Point(r.X, r.Y);}private static Size ToSize(Rect r){return new Size(r.Width, r.Height);} private static Point GetPointFromSize(Size size){return new Point(size.Width, size.Height);}private static Size GetSizeFromPoint(Point point){return new Size(Math.Max(point.X, 0), Math.Max(point.Y, 0));}private bool RecalculateCurrentPoint(Point current, Point target, Vector velocity, double seconds, double dampening, double attractionFactor, out Point newCurrentPoint, out Vector newVelocity){if (current != target){Vector diff = new Vector(target.X - current.X, target.Y - current.Y);if (diff.Length > this.SnapPrecision || velocity.Length > this.SnapPrecision){velocity.X *= (1 - dampening);velocity.Y *= (1 - dampening);velocity += diff;Vector delta = velocity * seconds * attractionFactor;double maxVelocity = 600;delta *= (delta.Length > maxVelocity) ? (maxVelocity / delta.Length) : 1;current.X += delta.X;current.Y += delta.Y;newCurrentPoint = current;newVelocity = velocity;return true;}else{newCurrentPoint = target;newVelocity = new Vector(0, 0);return true;}}else{newCurrentPoint = current;newVelocity = velocity;return false;}}public Rect GetElementRect(UIElement child){if (States.ContainsKey(child)){return States[child].CurrentRect;}else{return Rect.Empty;}} public class ElementState{static Random _Random = new Random();public ElementState(Rect targetRect, double randomness){CurrentRect = new Rect(0, 0, targetRect.Width, targetRect.Height);TargetRect = targetRect;LocationVelocity = new Vector(0, 0);SizeVelocity = new Vector(0, 0);AttractionMultiplier = (_Random.NextDouble() * randomness) + .4; }internal  Rect TargetRect;internal Rect CurrentRect;internal Vector LocationVelocity;internal Vector SizeVelocity;internal double AttractionMultiplier;internal bool NeedsArrange;}public struct Vector{public Vector(double xValue, double yValue){_xCoordinate = xValue;_yCoordinate = yValue;}internal double _xCoordinate;internal double _yCoordinate;public static bool operator ==(Vector vector1, Vector vector2){return ((vector1.X == vector2.X) && (vector1.Y == vector2.Y));}public static bool operator !=(Vector vector1, Vector vector2){return !(vector1 == vector2);}public static bool Equals(Vector vector1, Vector vector2){return (vector1.X.Equals(vector2.X) && vector1.Y.Equals(vector2.Y));}public override bool Equals(object obj){if ((obj == null) || !(obj is Vector)){return false;}Vector vector = (Vector)obj;return Equals(this, vector);}public bool Equals(Vector value){return Equals(this, value);}public override int GetHashCode(){return (this.X.GetHashCode() ^ this.Y.GetHashCode());}public double X{get{return _xCoordinate;}set{_xCoordinate = value;}}public double Y{get{return _yCoordinate;}set{_yCoordinate = value;}}public double Length{get{return Math.Sqrt((this.X * this.X) + (this.Y * this.Y));}}public double LengthSquared{get{return ((this.X * this.X) + (this.Y * this.Y));}}public void Normalize(){this = (Vector)(this / Math.Max(Math.Abs(this.X), Math.Abs(this.Y)));this = (Vector)(this / this.Length);}public static double CrossProduct(Vector vector1, Vector vector2){return ((vector1.X * vector2.Y) - (vector1.Y * vector2.X));}public static double AngleBetween(Vector vector1, Vector vector2){double y = (vector1.X * vector2.Y) - (vector2.X * vector1.Y);double x = (vector1.X * vector2.X) + (vector1.Y * vector2.Y);return (Math.Atan2(y, x) * 57.295779513082323);}public static Vector operator -(Vector vector){return new Vector(-vector.X, -vector.Y);}public void Negate(){this.X = -this.X;this.Y = -this.Y;}public static Vector operator +(Vector vector1, Vector vector2){return new Vector(vector1.X + vector2.X, vector1.Y + vector2.Y);}public static Vector Add(Vector vector1, Vector vector2){return new Vector(vector1.X + vector2.X, vector1.Y + vector2.Y);}public static Vector operator -(Vector vector1, Vector vector2){return new Vector(vector1.X - vector2.X, vector1.Y - vector2.Y);}public static Vector Subtract(Vector vector1, Vector vector2){return new Vector(vector1.X - vector2.X, vector1.Y - vector2.Y);}public static Point operator +(Vector vector, Point point){return new Point(point.X + vector.X, point.Y + vector.Y);}public static Point Add(Vector vector, Point point){return new Point(point.X + vector.X, point.Y + vector.Y);}public static Vector operator *(Vector vector, double scalar){return new Vector(vector.X * scalar, vector.Y * scalar);}public static Vector Multiply(Vector vector, double scalar){return new Vector(vector.X * scalar, vector.Y * scalar);}public static Vector operator *(double scalar, Vector vector){return new Vector(vector.X * scalar, vector.Y * scalar);}public static Vector Multiply(double scalar, Vector vector){return new Vector(vector.X * scalar, vector.Y * scalar);}public static Vector operator /(Vector vector, double scalar){return (Vector)(vector * (1.0 / scalar));}public static Vector Divide(Vector vector, double scalar){return (Vector)(vector * (1.0 / scalar));}public static double operator *(Vector vector1, Vector vector2){return ((vector1.X * vector2.X) + (vector1.Y * vector2.Y));}public static double Multiply(Vector vector1, Vector vector2){return ((vector1.X * vector2.X) + (vector1.Y * vector2.Y));}public static double Determinant(Vector vector1, Vector vector2){return ((vector1.X * vector2.Y) - (vector1.Y * vector2.X));}public static explicit operator Size(Vector vector){return new Size(Math.Abs(vector.X), Math.Abs(vector.Y));}public static explicit operator Point(Vector vector){return new Point(vector.X, vector.Y);}}}"));
            Collection.Add(new HSLItem("Custom Control - Custom Cursor", "customcontrol~control~xaml~csharp~customcursor~grid~uielement", "public class FX : Grid { private static Canvas ThisWrapper = null; private static UIElement TheCursor = null; public static readonly DependencyProperty CustomCursorProperty = DependencyProperty.RegisterAttached(\"CustomCursor\", typeof(UIElement), typeof(FX), new PropertyMetadata(new PropertyChangedCallback(OnCursorChanged))); private static void OnCursorChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { FrameworkElement ThisElement = DpObj as FrameworkElement; if (ThisElement != null) { ThisElement.Cursor = Cursors.None; ThisElement.MouseEnter += new MouseEventHandler(TheCursor_MouseEnter); ThisElement.MouseLeave += new MouseEventHandler(TheCursor_MouseLeave); ThisElement.MouseMove += new MouseEventHandler(TheCursor_MouseMove); } } public static UIElement GetCustomCursor(DependencyObject DpObj) { return DpObj.GetValue(CustomCursorProperty) as UIElement; } public static void SetCustomCursor(DependencyObject DpObj, UIElement Parent) { DpObj.SetValue(CustomCursorProperty, Parent); } static void TheCursor_MouseMove(object sender, MouseEventArgs e) { FrameworkElement ThisElement = sender as FrameworkElement; Point p = e.GetPosition(ThisElement); Canvas.SetLeft(TheCursor, p.X); Canvas.SetTop(TheCursor, p.Y); } static void TheCursor_MouseLeave(object sender, MouseEventArgs e) { FrameworkElement ThisElement = sender as FrameworkElement; ((Grid)(ThisElement)).Children.Remove(ThisWrapper); ThisWrapper.Children.Remove(TheCursor); TheCursor = null; ThisWrapper = null; } static void TheCursor_MouseEnter(object sender, MouseEventArgs e) { FrameworkElement ThisElement = sender as FrameworkElement; TheCursor = GetCustomCursor(ThisElement);ThisWrapper = new Canvas(); ThisWrapper.Children.Add(TheCursor); ((Grid)(ThisElement)).Children.Add(ThisWrapper); Point p = e.GetPosition(ThisElement); Canvas.SetLeft(TheCursor, p.X); Canvas.SetTop(TheCursor, p.Y); } } <hsl:FX x:Name=\"CustomCursorTest\" Grid.Row=\"1\"><Grid x:Name=\"something\" Height=\"50\" ><hsl:FX.CustomCursor><Rectangle Width=\"10\" Height=\"10\" Fill=\"Green\" /></hsl:FX.CustomCursor> <Rectangle Opacity=\".5\" Fill=\"Red\" /><TextBlock Text=\"CustomCursor\" /></Grid></hsl:FX>"));
            Collection.Add(new HSLItem("Custom Control Usage", "customcontrol~xaml~control~customcontrol~namespace", "<cntrls:ContentControl Width=\"500\" Height=\"300\" ><cntrls:ContentControl.DisplayContent><vws:Twitter DisplayTitle=\"Our Twitters\" FeedAddress=\"http://www.hackingsilverlight.net/twitter.asp\" BackSide=\"False\" /></cntrls:ContentControl.DisplayContent> </cntrls:ContentControl>"));
            Collection.Add(new HSLItem("Custom Event", "customevent~xaml~csharp~event", "// CUSTOM EVENT ARGUMENT : public class DialEventArgs : EventArgs { private double angle; public DialEventArgs(double _Angle) { this.angle = _Angle; } public double Angle { get { return angle; } } } // DEFINE EVENT IN CONTROL CLASS: public event PositionChangeHandler PositionChangedEvent; protected virtual void OnPositionChanged(DialEventArgs e){PositionChangedEvent(this, e);}//TO CALL THE EVENT IN THE CONTROLOnPositionChanged(new DialEventArgs(AngleOfRotation));// IN THE XAML IT MIGHT LOOK LIKE:<cc:Dial x:Name=\"NewKnobControl\" Height=\"100\" Width=\"100\" PositionChangedEvent=\"NewKnobControl_PositionChangedEvent\" Minimum=\"45.0\" Max=\"135\" > <cc:Dial.KnobFace><Grid > <Ellipse Fill=\"Aquamarine\" /><Rectangle x:Name=\"Indicator\" Height=\"10\" Width=\"49\" Fill=\"Blue\" Margin=\"1,45,50,45\"  /></Grid></cc:Dial.KnobFace></cc:Dial>"));
            Collection.Add(new HSLItem("Databinding - Simple", "databinding~xaml~csharp", "using System.ComponentModel; using System.Collections.ObjectModel; public class Data : INotifyPropertyChanged { private object _value; public event PropertyChangedEventHandler PropertyChanged; public Data(object val) { _value = val;this.itemsControl.DataContext = GetData(); } private void NotifyPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } public object Value { get { return _value; } set { if (value != _value) { _value = value; NotifyPropertyChanged(\"Value\"); } } } public class DataCollection : ObservableCollection<Data> { } private object GetData() { DataCollection MyCollection = new DataCollection(); MyCollection.Add(new Data(\"One\")); MyCollection.Add(new Data(\"Two\"));  return MyCollection; } } <UserControl.Resources><DataTemplate x:Name=\"MyDataTemplate\" ><TextBlock Text=\"{Binding Value}\" ></TextBlock></DataTemplate></UserControl.Resources><ItemsControl x:Name=\"itemsControl\" ItemsSource=\"{Binding}\" ItemTemplate=\"{StaticResource MyDataTemplate}\" ></ItemsControl>"));
            Collection.Add(new HSLItem("Databinding - RSS", "databinding~xaml~rss~csharp~xml", "<ItemsControl x:Name=\"FeedList\" Visibility=\"Visible\" Canvas.Left=\"90\" Canvas.Top=\"16\" Width=\"201\"  ><ItemsControl.ItemTemplate><DataTemplate><StackPanel Margin=\"0 0 0 10\"><TextBlock x:Name=\"FeedMsg\"  Opacity=\"0.6\" FontFamily=\"Verdana\" FontSize=\"13\" Foreground=\"#FFB5FE69\" Text=\"{Binding Title.Text}\" TextAlignment=\"Left\" TextWrapping=\"Wrap\"/><TextBlock x:Name=\"FeedSlideAgo\" Opacity=\"0.245\" FontFamily=\"Verdana\" FontSize=\"10\" Foreground=\"#FFE5E9F4\" Text=\"{Binding PublishDate.LocalDateTime}\" TextAlignment=\"Right\" TextWrapping=\"Wrap\" Height=\"17\"/> </StackPanel></DataTemplate></ItemsControl.ItemTemplate></ItemsControl> WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); client.DownloadStringAsync(new Uri(TargetAddress)); _DisplayCount = DisplayCount; void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (!string.IsNullOrEmpty(e.Result)) { XmlReader feedReader = XmlReader.Create(new StringReader(e.Result)); SyndicationFeed feed = SyndicationFeed.Load(feedReader); _Target.ItemsSource = feed.Items.Take(_DisplayCount); } } catch (Exception) { } } "));
            Collection.Add(new HSLItem("Datagrid", "datagrid~xaml~control~binding~databinding", "<Data:DataGrid x:Name=\"itemsControl\" AutoGenerateColumns=\"True\" ItemsSource=\"{Binding}\"  />"));
            Collection.Add(new HSLItem("Datatemplate", "datatemplate~xaml~binding~databinding", "<DataTemplate x:Name=\"MyDataTemplate\" ><TextBlock Text=\"{Binding Value}\" ></TextBlock></DataTemplate>"));
            Collection.Add(new HSLItem("Dispatcher Timer", "dispatcher~dispatchertimer~thread~multithreaded~timer", "// ON CLASS : private System.Windows.Threading.DispatcherTimer MyTimer = new System.Windows.Threading.DispatcherTimer();   // IN SAY THE CONSTRUCTOR : MyTimer.Interval = new TimeSpan(0, 0, 0 , 0, 1); MyTimer.Tick += new EventHandler(Timer_Completed); MyTimer.Start();// REALLY? YOU CAN'T FIGURE THIS ONE OUT??? : private void Timer_Completed(object sender, EventArgs e)"));
            Collection.Add(new HSLItem("Dial Control", "dialcontrol~dial~control~resourcedictionary~xaml~csharp~template~setter~customcontrol", "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:vsm=\"clr-namespace:System.Windows;assembly=System.Windows\" xmlns:hsl=\"clr-namespace:HackingSilverlightLibrary\" > <Style TargetType=\"hsl:Dial\"><Setter Property=\"Template\"><Setter.Value><ControlTemplate TargetType=\"hsl:Dial\"><Grid x:Name=\"Knob\" Background=\"Transparent\" ><ContentPresenter x:Name=\"Background\" Content=\"{TemplateBinding KnobBackground}\"/><ContentPresenter x:Name=\"DialKnob\" Content=\"{TemplateBinding KnobFace}\" RenderTransformOrigin=\"0.483,0.479\" ><ContentPresenter.RenderTransform><TransformGroup><RotateTransform x:Name=\"DialAngle\" Angle=\"0\" /></TransformGroup></ContentPresenter.RenderTransform></ContentPresenter></Grid></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary> public class Dial : Control { Grid Knob = null; RotateTransform DialAngle = null; private Boolean IHaveMouse = false; public static readonly DependencyProperty SetDegreeProperty = DependencyProperty.Register(\"SetDegree\", typeof(double), typeof(Dial), new PropertyMetadata(new PropertyChangedCallback(OnSetDegreeChanged))); public double SetDegree { get { return (double)GetValue(SetDegreeProperty); } set { SetValue(SetDegreeProperty, value); } } private static void OnSetDegreeChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { } public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(\"Minimum\", typeof(double), typeof(Dial), new PropertyMetadata(new PropertyChangedCallback(OnMinimumChanged))); public double Minimum { get { return (double)GetValue(MinimumProperty); } set { SetValue(MinimumProperty, value); } } private static void OnMinimumChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { } public static readonly DependencyProperty MaxProperty = DependencyProperty.Register(\"Max\", typeof(double), typeof(Dial), new PropertyMetadata(new PropertyChangedCallback(OnMaxChanged))); public double Max { get { return (double)GetValue(MaxProperty); } set { SetValue(MaxProperty, value); } } private static void OnMaxChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { } public UIElement KnobFace { get { return (UIElement)GetValue(KnobFaceProperty); } set { SetValue(KnobFaceProperty, value); } } public static readonly DependencyProperty KnobFaceProperty = DependencyProperty.Register(\"KnobFace\", typeof(UIElement), typeof(Dial), new PropertyMetadata(null)); public UIElement KnobBackground { get { return (UIElement)GetValue(KnobBackgroundProperty); } set { SetValue(KnobBackgroundProperty, value); } } public static readonly DependencyProperty KnobBackgroundProperty = DependencyProperty.Register(\"KnobBackground\", typeof(UIElement), typeof(Dial), new PropertyMetadata(null)); public Dial() { this.DefaultStyleKey = typeof(Dial); } public override void OnApplyTemplate() { Knob = ((Grid)GetTemplateChild(\"Knob\")); DialAngle = ((RotateTransform)GetTemplateChild(\"DialAngle\")); Knob.MouseLeftButtonUp += new MouseButtonEventHandler(Knob_MouseLeftButtonUp); Knob.MouseLeave += new MouseEventHandler(Knob_MouseLeave); Knob.MouseLeftButtonDown += new MouseButtonEventHandler(Knob_MouseLeftButtonDown); Knob.MouseMove += new MouseEventHandler(Knob_MouseMove); base.OnApplyTemplate(); if (Minimum > 0 && Minimum < 360) { SetPosition(Minimum); } }  private void Knob_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { IHaveMouse = false; } private void Knob_MouseLeave(object sender, MouseEventArgs e) { IHaveMouse = false; } private void Knob_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { IHaveMouse = true; SetPosition(GetAngle(e.GetPosition(Knob))); } private void Knob_MouseMove(object sender, MouseEventArgs e) { if (IHaveMouse) { SetPosition(GetAngle(e.GetPosition(Knob))); } } private void SetPosition(double AngleOfRotation) { if (Minimum > 0 && Max > 0 && Minimum < 360 && Max <= 360) { if (AngleOfRotation < Minimum) { AngleOfRotation = Minimum; } if (AngleOfRotation > Max) { AngleOfRotation = Max; } } DialAngle.Angle = AngleOfRotation; OnPositionChanged(new DialEventArgs(AngleOfRotation)); } double GetAngle(Point NewPoint) { double TheDiameter = Knob.ActualWidth; double CurrentHeight = Knob.ActualHeight; double Radius = TheDiameter / 2; double AngleOfRotation = AngleOfRotationQuadrant(TheDiameter, CurrentHeight, NewPoint); if ((NewPoint.X > Radius) && (NewPoint.Y <= Radius)) {  AngleOfRotation = 90.0 + (90.0 - AngleOfRotation); } else if ((NewPoint.X > Radius) && (NewPoint.Y > Radius)) {  AngleOfRotation = 180.0 + AngleOfRotation; } else if ((NewPoint.X < Radius) && (NewPoint.Y > Radius)) { AngleOfRotation = 270.0 + (90.0 - AngleOfRotation); } return AngleOfRotation; } double AngleOfRotationQuadrant(double CurrentWidth, double CurrentHeight, Point NewPoint) { double DialRadius = CurrentWidth / 2; Point CenterPoint = new Point(DialRadius, CurrentHeight / 2); Point StartPoint = new Point(0, CurrentHeight / 2); double TriangleTop = Math.Sqrt(ToThePowerOfTwo(NewPoint.X - CenterPoint.X) + ToThePowerOfTwo(CenterPoint.Y - NewPoint.Y)); double TriangleHeight = (NewPoint.Y > CenterPoint.Y) ? NewPoint.Y - CenterPoint.Y : CenterPoint.Y - NewPoint.Y; return ((TriangleHeight * Math.Sin(90.0)) / TriangleTop) * 100; } double ToThePowerOfTwo(double n1) { return n1 * n1; } public event PositionChangeHandler PositionChangedEvent; protected virtual void OnPositionChanged(DialEventArgs e) { PositionChangedEvent(this, e); } } public class DialEventArgs : EventArgs { private double angle; public DialEventArgs(double _Angle) { this.angle = _Angle; } public double Angle { get { return angle; } } } public delegate void PositionChangeHandler(object sender, DialEventArgs e); <hsl:Dial x:Name=\"NewKnobControl\" Height=\"125\" Width=\"125\" PositionChangedEvent=\"NewKnobControl_PositionChangedEvent\" ><hsl:Dial.KnobBackground></hsl:Dial.KnobBackground><hsl:Dial.KnobFace></hsl:Dial.KnobFace></hsl:Dial>"));
            Collection.Add(new HSLItem("DOM Bridge", "htmlbridge~dombridge~csharp~hack", "System.Windows.Browser.HtmlPage.Window.Alert(\"asdf\"); private void InsertECMAScript(string JavaScript) {    HtmlElement Script = HtmlPage.Document.CreateElement(\"script\");    Script.SetAttribute(\"type\", \"text/javascript\");    Script.SetProperty(\"text\", JavaScript);    HtmlPage.Document.DocumentElement.AppendChild(Script); } HtmlPage.Document.GetElementById(\"HistoryTarget\").SetAttribute(\"innerHTML\", \"<b>No iframes for you</b>\");"));
            Collection.Add(new HSLItem("DoubleAnimation", "doubleanimation~xaml~animation~storyboard", "<DoubleAnimation Storyboard.TargetName=\"PolygonElement\" Storyboard.TargetProperty=\"(Canvas.Left)\" From=\"5\" To=\"48\" Duration=\"0:0:3\" BeginTime=\"00:00:02\" />"));
            Collection.Add(new HSLItem("DoubleAnimationUsingKeyFrames", "doubleanimationusingkeyframes~xaml~animation", "<DoubleAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"path\" Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)\"><SplineDoubleKeyFrame KeyTime=\"00:00:01\" Value=\"1.06\"/></DoubleAnimationUsingKeyFrames>"));
            Collection.Add(new HSLItem("Double Click - Hack", "double~click~hack~csharp", "public long LastTicks = 0; // in event handler : if ((DateTime.Now.Ticks - LastTicks) < 2310000) { // double click code here : } LastTicks = DateTime.Now.Ticks;"));
            Collection.Add(new HSLItem("DropShadowEffect", "dropshadoweffect~xaml~image~pixelshader~shader~bitmapeffect", "<DropShadowEffect Color=\"#FF5E6D8D\" BlurRadius=\"2\" ShadowDepth=\"2\"/> "));
            Collection.Add(new HSLItem("Easing", "doubleanimation~easing~xaml~animation", "<DoubleAnimation From=\"0\" To=\"300\" Duration=\"0:0:10\" Storyboard.Target=\"foobar1\"><DoubleAnimation.EasingFunction><BounceEase Bounces=\"5\" EasingMode=\"EaseIn\" Bounciness=\"3\" ></BounceEase></DoubleAnimation.EasingFunction></DoubleAnimation> "));
            Collection.Add(new HSLItem("Ellipse", "ellipse~circle~xaml~shape", "// CIRCLE : <Ellipse Name=\"EllipseElement\" Height=\"100\" Width=\"100\" 		Canvas.Left=\"50\" Canvas.Top=\"50\" Fill=\"#728f4a\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" />// OVAL: <Ellipse Name=\"EllipseElement\" Height=\"100\" Width=\"300\" Canvas.Left=\"50\" Canvas.Top=\"50\" Fill=\"#728f4a\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" />"));
            Collection.Add(new HSLItem("Events", "events~csharp", "// EVENT Loaded : void Page_Loaded(object o, EventArgs e) // EVENT MouseLeftButtonDown : void StaturBar_MouseLeftButtonDown(object sender, MouseEventArgs e) // EVENT MouseLeftButtonUp : void StaturBar_MouseLeftButtonUp(object sender, MouseEventArgs e) // EVENT KeyDown : // EVENT KeyUp : // EVENT MouseEnter : void StaturBar_MouseEnter(object sender, MouseEventArgs e) // EVENT MouseLeave : void StaturBar_MouseLeave(object sender, MouseEventArgs e)	// EVENT MouseMove : void StaturBar_MouseMove(object sender, MouseEventArgs e ) // EVENT Click : MyButton.MouseLeftButtonDown += new MouseEventHandler(MyButton_Click); void MyButton_Click(object sender, MouseEventArgs e)"));
            Collection.Add(new HSLItem("EventTrigger", "eventtrigger~xaml~animation~storyboard", "<EventTrigger RoutedEvent=\"Canvas.Loaded\"><EventTrigger.Actions><BeginStoryboard><Storyboard>// ANIMATIONS GO HERE... : </Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Canvas.Triggers>"));
            Collection.Add(new HSLItem("Flip FX Control", "generic.xaml~template~flip~animation~xaml~csharp~control~flipfx~fxflip~style~customcontrol", "// fxflip class template in Generic.xaml : <Style TargetType=\"hsl:FXFlip\"><Setter Property=\"Template\"><Setter.Value><ControlTemplate TargetType=\"hsl:FXFlip\"><Border ><vsm:VisualStateManager.VisualStateGroups><vsm:VisualStateGroup x:Name=\"VisualStateGroup\"><vsm:VisualState x:Name=\"FlipState1\"><Storyboard><DoubleAnimation Storyboard.TargetName=\"FrontScale\" Storyboard.TargetProperty=\"ScaleX\" To=\"0\" Duration=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"FrontScale\" Storyboard.TargetProperty=\"ScaleY\" To=\".95\" Duration=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"FrontPanel\" Storyboard.TargetProperty=\"Opacity\" To=\"0\" Duration=\"0:0:.1\" BeginTime=\"0:0:.1\" /><DoubleAnimation Storyboard.TargetName=\"BackPanel\" Storyboard.TargetProperty=\"Opacity\" To=\"1\" Duration=\"0:0:.1\" BeginTime=\"0:0:.1\" /><DoubleAnimation Storyboard.TargetName=\"BackScale\" Storyboard.TargetProperty=\"ScaleX\" To=\"1\" Duration=\"0:0:.2\" BeginTime=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"BackScale\" Storyboard.TargetProperty=\"ScaleY\" To=\"1\" Duration=\"0:0:.2\" BeginTime=\"0:0:.2\" /></Storyboard></vsm:VisualState><vsm:VisualState x:Name=\"FlipState2\"><Storyboard><DoubleAnimation Storyboard.TargetName=\"BackScale\" Storyboard.TargetProperty=\"ScaleX\" To=\"0\" Duration=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"BackScale\" Storyboard.TargetProperty=\"ScaleY\" To=\".95\" Duration=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"BackPanel\" Storyboard.TargetProperty=\"Opacity\" To=\"0\" Duration=\"0:0:.1\" BeginTime=\"0:0:.1\" /><DoubleAnimation Storyboard.TargetName=\"FrontPanel\" Storyboard.TargetProperty=\"Opacity\" To=\"1\" Duration=\"0:0:.1\" BeginTime=\"0:0:.1\" /><DoubleAnimation Storyboard.TargetName=\"FrontScale\" Storyboard.TargetProperty=\"ScaleX\" To=\"1\" Duration=\"0:0:.2\" BeginTime=\"0:0:.2\" /><DoubleAnimation Storyboard.TargetName=\"FrontScale\" Storyboard.TargetProperty=\"ScaleY\" To=\"1\" Duration=\"0:0:.2\" BeginTime=\"0:0:.2\" /></Storyboard></vsm:VisualState></vsm:VisualStateGroup></vsm:VisualStateManager.VisualStateGroups> <Grid x:Name=\"ContentPresenters\" Background=\"Transparent\" ><ContentPresenter x:Name=\"FrontPanel\" Content=\"{TemplateBinding Front}\"  RenderTransformOrigin=\"0.5,0.5\"  ><ContentPresenter.RenderTransform><TransformGroup><ScaleTransform x:Name=\"FrontScale\" ScaleX=\"1\" ScaleY=\"1\"/></TransformGroup></ContentPresenter.RenderTransform></ContentPresenter><ContentPresenter x:Name=\"BackPanel\" Content=\"{TemplateBinding Back}\" Opacity=\"0\" RenderTransformOrigin=\"0.5,0.5\" ><ContentPresenter.RenderTransform><TransformGroup><ScaleTransform x:Name=\"BackScale\" ScaleX=\"0\" ScaleY=\".95\"/></TransformGroup></ContentPresenter.RenderTransform></ContentPresenter> </Grid></Border></ControlTemplate></Setter.Value></Setter></Style> // fxflip class : public class FXFlip : Control { public FXFlip() { Flip = false; AutoFlip = false; } public override void OnApplyTemplate() { if (Flip) { if (AutoFlip) { ((Grid)GetTemplateChild(\"ContentPresenters\")).MouseLeftButtonDown += new MouseButtonEventHandler(FXFlip_MouseLeftButtonDown); } } base.OnApplyTemplate(); }  private bool _FXFront = true; void FXFlip_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { ExecuteFlip(); } public void ExecuteFlip() { if (Flip) { VisualStateManager.GoToState(this, ((_FXFront) ? \"FlipState1\" : \"FlipState2\"), true); _FXFront = !_FXFront; } } public static readonly DependencyProperty AutoFlipProperty = DependencyProperty.Register(\"AutoFlip\", typeof(bool), typeof(FXFlip), new PropertyMetadata(new PropertyChangedCallback(OnAutoFlipChanged))); public bool AutoFlip { get { return (bool)GetValue(AutoFlipProperty); } set { SetValue(AutoFlipProperty, value); } } private static void OnAutoFlipChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { FXFlip ThisElement = DpObj as FXFlip; if (ThisElement != null) { ThisElement.Flip = true; } } public static readonly DependencyProperty FlipProperty = DependencyProperty.Register(\"Flip\", typeof(bool), typeof(FXFlip), new PropertyMetadata(new PropertyChangedCallback(OnFlipChanged))); public bool Flip { get { return (bool)GetValue(FlipProperty); } set { SetValue(FlipProperty, value); } } private static void OnFlipChanged(DependencyObject DpObj, DependencyPropertyChangedEventArgs e) { FXFlip ThisElement = DpObj as FXFlip; if (ThisElement != null) { ThisElement.DefaultStyleKey = typeof(FXFlip);  } } public static readonly DependencyProperty FrontProperty = DependencyProperty.Register(\"Front\", typeof(UIElement), typeof(FXFlip), new PropertyMetadata(null)); public UIElement Front { get { return (UIElement)GetValue(FrontProperty); } set { SetValue(FrontProperty, value); } } public static readonly DependencyProperty BackProperty = DependencyProperty.Register(\"Back\", typeof(UIElement), typeof(FXFlip), new PropertyMetadata(null)); public UIElement Back { get { return (UIElement)GetValue(BackProperty); } set { SetValue(BackProperty, value); } } } <hsl:FXFlip x:Name=\"FlipTest\" Flip=\"True\" AutoFlip=\"True\"><hsl:FXFlip.Front><Grid x:Name=\"frontgrid\" Height=\"50\" ><Rectangle Opacity=\".5\" Fill=\"Tan\" /><TextBlock Text=\"front\" /></Grid></hsl:FXFlip.Front><hsl:FXFlip.Back><Grid x:Name=\"backgrid\" Height=\"50\" ><Rectangle Opacity=\".5\" Fill=\"Gray\" /><TextBlock Text=\"back\" /></Grid></hsl:FXFlip.Back></hsl:FXFlip>"));
            Collection.Add(new HSLItem("Font - Custom", "customfont~font~text~textblock~xaml", "<TextBlock Height=\"56\" Width=\"260\" FontFamily=\"./Fonts/Digir___.ttf#Digital Readout\" Text=\"0 1 2 3 4 5 6 7 8 9\" Visibility=\"Collapsed\" />"));
            Collection.Add(new HSLItem("Forcing Execution on the UI Thread (hack)", "hack~dispatcher~begininvoke~forcingexecutionontheuithread~csharp~thread~multithreaded", "Dispatcher.BeginInvoke(delegate() { // SOME CODE HERE : });"));
            Collection.Add(new HSLItem("FullScreen", "fullscreen~csharp", "Application.Current.Host.Content.FullScreenChanged += new EventHandler(TopElement_OnFullScreenChanged); private void TopElement_OnFullScreenChanged(object sender, EventArgs e) { TopElement.Width = Application.Current.Host.Content.ActualWidth; TopElement.Height = Application.Current.Host.Content.ActualHeight; } if( SLHost.Content.IsFullScreen )  { SLHost.Content.IsFullScreen = false; } else  { SLHost.Content.IsFullScreen = true; }"));
            Collection.Add(new HSLItem("GetColor Method", "color~csharp~getcolor~calculatecolor~string", "public static Color GetColor(string ThisColorCode){Color c = new Color();switch (ThisColorCode.Length){case 6:c.A = Convert.ToByte(255);c.R = Convert.ToByte(ThisColorCode.Substring(0, 2), 16);c.G = Convert.ToByte(ThisColorCode.Substring(2, 2), 16);c.B = Convert.ToByte(ThisColorCode.Substring(4, 2), 16);break;case 7:c.A = Convert.ToByte(255);c.R = Convert.ToByte(ThisColorCode.Substring(1, 2), 16);c.G = Convert.ToByte(ThisColorCode.Substring(3, 2), 16);c.B = Convert.ToByte(ThisColorCode.Substring(5, 2), 16);break;case 8:c.A = Convert.ToByte(ThisColorCode.Substring(0, 2), 16);c.R = Convert.ToByte(ThisColorCode.Substring(2, 2), 16);c.G = Convert.ToByte(ThisColorCode.Substring(4, 2), 16);c.B = Convert.ToByte(ThisColorCode.Substring(6, 2), 16);break;case 9:c.A = Convert.ToByte(ThisColorCode.Substring(1, 2), 16);c.R = Convert.ToByte(ThisColorCode.Substring(3, 2), 16);c.G = Convert.ToByte(ThisColorCode.Substring(5, 2), 16);c.B = Convert.ToByte(ThisColorCode.Substring(7, 2), 16); break;}return c;}"));
            Collection.Add(new HSLItem("Glyph", "xaml~glyphs~text", "<Glyphs Name=\"MyGlyph\" ContUrl=\"font.ttf\" Canvas.top=\"10\" Canvas.Left=\"10\" fontRenderingEmSize=\"12\" Fill=\"#999999\" UnicodeString=\"[some uni code character string]\" />"));
            Collection.Add(new HSLItem("GradientStop", "xaml~rectangle~gradientstop~lineargradientbrush", "<Rectangle.Stroke><LinearGradientBrush EndPoint=\"1.041,0.657\" StartPoint=\"-0.041,0.343\"><GradientStop Color=\"#994E71BE\" Offset=\"0\"/><GradientStop Color=\"#194664A7\" Offset=\"1\"/></LinearGradientBrush></Rectangle.Stroke>"));
            Collection.Add(new HSLItem("Grid", "grid~xaml~layout", "<Grid x:Name=\"LayoutRoot\"><Grid.Triggers><EventTrigger RoutedEvent=\"Grid.Loaded\"><EventTrigger.Actions><BeginStoryboard><Storyboard >...</Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Grid.Triggers><Grid.Background><RadialGradientBrush GradientOrigin=\"0.119,0.96\" Center=\"0.145,0.954\" RadiusX=\"1.253\" RadiusY=\"0.976\"><RadialGradientBrush.RelativeTransform><TransformGroup>...</TransformGroup></RadialGradientBrush.RelativeTransform><GradientStop Color=\"#FF2A5FAD\" Offset=\"0.264\"/><GradientStop Color=\"#FF0D317D\" Offset=\"0.836\"/></RadialGradientBrush></Grid.Background><Grid.RowDefinitions><RowDefinition Height=\"*\"></RowDefinition><RowDefinition Height=\"300\" /></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width=\"0.021*\"/><ColumnDefinition Width=\"0.656*\"/><ColumnDefinition Width=\"0.323*\"/></Grid.ColumnDefinitions></Grid>"));
            Collection.Add(new HSLItem("Hard URL", "hardurl~dombridge~browser~url~uri", "if (Source.IndexOf(\"http\") < 0) {    string URL = System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri    Source = URL.Substring(0, URL.LastIndexOf('/')) + \"/\" + Source;   } "));
            Collection.Add(new HSLItem("HTA (HTml Application)", "htmlapplication~html~hta~hack", "<HTA:APPLICATION id=\"oVDProcess\" applicationName=\"Virtual Desktop - Lite\" singleinstance=\"yes\" caption=\"no\" contextmenu=\"no\" innerborder=\"no\" scroll=\"no\" showintaskbar=\"no\" version=\"1.0.032\" SELECTION=\"no\" windowState=\"normal\" icon=\"im_gray.ico\" />")); 
            Collection.Add(new HSLItem("HTML DOM Bridge - Add Event Listener", "addeventlistener~htmlbridge~csharp~hack", "rootElement.addEventListener(\"KeyDown\",Silverlight.createDelegate(this, this.rootElement_KeyDown));"));
            Collection.Add(new HSLItem("HTML DOM Bridge - C# Eval", "htmldombridge~hack~htmlbridge~eval~insertecmascript", "private static string ClientSideEvalName = string.Empty; private static ScriptObject ClientSideEvalFunction = null; public static ScriptObject eval(string ECMACode) { if (string.IsNullOrEmpty(ClientSideEvalName)) { ClientSideEvalName = \"eval\" + (Guid.NewGuid().ToString().Replace('-', 'x')); InsertECMAScript(\"function \" + ClientSideEvalName + \"(InputValue) { return eval(InputValue); }\"); ClientSideEvalFunction = (ScriptObject)HtmlPage.Window.GetProperty(ClientSideEvalName); } return (ScriptObject)(ClientSideEvalFunction.InvokeSelf(ECMACode)); }"));
            Collection.Add(new HSLItem("HTML DOM Bridge - HTML Side", "html~dombridge~csharp", "System.Windows.Browser.HtmlPage.Window.Alert(\"asdf\"); private void InsertECMAScript(string JavaScript) {    HtmlElement Script = HtmlPage.Document.CreateElement(\"script\");    Script.SetAttribute(\"type\", \"text/javascript\");    Script.SetProperty(\"text\", JavaScript);    HtmlPage.Document.DocumentElement.AppendChild(Script); } HtmlPage.Document.GetElementById(\"HistoryTarget\").SetAttribute(\"innerHTML\", \"<b>No iframes for you</b>\"); using System.Windows.Browser; ScriptObject MyJavaScriptFunction = (ScriptObject)HtmlPage.Window.GetProperty(\"doMask\"); MyFirstMaskEditControl.Text = (string)(MyJavaScriptFunction.InvokeSelf((MyFirstMaskEditControl.Text + \"~999\").Split('~'))); "));
            Collection.Add(new HSLItem("HTML DOM Bridge - C# Side", "html~dombridge~javascript~jscript~ecma~csharp", "HtmlPage.RegisterScriptableObject(\"Page\", this); [ScriptableMember] public void iNotify(string arg) { TestButtonTxt.Text = \"Page: \" + arg;    } // ECMA :  function OnMouseWheel()  { ($get('Xaml1')).content.MySilverlightObject.MouseWheel(window.event.clientX, window.event.clientY, window.event.wheelDelta);  } "));
            Collection.Add(new HSLItem("HTML DOM Bridge - Call JavaScript Function", "ecma~javascript~htmlbridge~htmldombridge~csharp", "// object member : ScriptObject MyJavaScriptFunction = null; // in constructor : MyJavaScriptFunction = (ScriptObject)HtmlPage.Window.GetProperty(\"doMask\"); // in keyup event : MyFirstMaskEditControl.Text = (string)(MyJavaScriptFunction.InvokeSelf((MyFirstMaskEditControl.Text + \"~999\").Split('~')));"));
            Collection.Add(new HSLItem("HTML DOM Bridge - Set Property", "html~dombridge~csharp~htmlpage~getelementbyid~setproperty", "HtmlPage.Document.GetElementById(\"HistoryTarget\").SetAttribute(\"innerHTML\", \"<b>No iframes for you</b>\");"));
            Collection.Add(new HSLItem("Image", "image~xaml~media", "<Image Name=\"ImageElement1\" Source=\"SL_banner_02.png\" Stretch=\"None\" Height=\"100\" Width=\"100\" Canvas.Left=\"100\" Canvas.Top=\"100\" Opacity=\".5\" />"));
            Collection.Add(new HSLItem("ImageBrush", "polygon~xaml~imagebrush~media~image", "<Polygon Name=\"PolygonElement\" Points=\"10,10 150,150 150,25\" Stroke=\"#3c5f0c\" StrokeThickness=\"1\"   ><Polygon.Fill><ImageBrush ImageSource=\"SL_banner_02.png\"/></Polygon.Fill></Polygon>"));
            Collection.Add(new HSLItem("Image Source", "imagesource~uri~csharp~image", "BitmapImage bmi = new BitmapImage(new Uri(ThisPlayer.CoverImage, UriKind.RelativeOrAbsolute)); PreloadedImg.Source = bmi;"));
            Collection.Add(new HSLItem("Init Param", "inputparameter~initparam~html~csharp", "// HTML MARKUP : <param name=\"initParams\" value=\"test=value1\" /> // IN App.xaml.cs (C#) : private void Application_Startup(object sender, StartupEventArgs e) { this.RootVisual = new MainPage(); KeyValue = e.InitParams[\"test\"].ToString(); } "));
            Collection.Add(new HSLItem("Inserting JavaScript into the DOM", "insertingjavascript~javascript~jscript~ecma~dombridge~dom~csharp~htmldombridge~insertecmascript~hack", "private void InsertECMAScript(string JavaScript) { HtmlElement Script = HtmlPage.Document.CreateElement(\"script\"); Script.SetAttribute(\"type\", \"text/javascript\"); Script.SetProperty(\"text\", JavaScript); HtmlPage.Document.DocumentElement.AppendChild(Script); }"));
            Collection.Add(new HSLItem("Install Experience", "html~installexperience", "<body background=\"Img/ScreenShot.png\" ><object id=\"SilverlightControlObj\" name=\"SilverlightControlObjNm\" data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100%\" height=\"100%\"><param name=\"source\" value=\"ClientBin/SUGWTK.xap\"/><param name=\"onError\" value=\"onSilverlightError\" /><param name=\"background\" value=\"white\" /><param name=\"minRuntimeVersion\" value=\"3.0.40624.0\" /><param name=\"autoUpgrade\" value=\"true\" /> <br />&nbsp;<br /><center>...</center>  </object>"));
            Collection.Add(new HSLItem("ItemsControl", "xaml~itemscontrol~control", "<ItemsControl x:Name=\"itemsControl\" ItemsSource=\"{Binding}\" ItemTemplate=\"{StaticResource MyDataTemplate}\" ></ItemsControl>"));
            Collection.Add(new HSLItem("Line", "xaml~line~shape", "<Line Name=\"LineElement\" X1=\"10\" Y1=\"10\" X2=\"150\" Y2=\"150\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" />"));
            Collection.Add(new HSLItem("LinearGradientBrush", "polygon~xaml~lineargradientbrush~gradientstop", "<Polygon Name=\"PolygonElement\" Points=\"10,10 150,150 150,25\"Stroke=\"#3c5f0c\" StrokeThickness=\"3\"   ><Polygon.Fill><LinearGradientBrush StartPoint=\"0,0\" EndPoint=\"1,0\"><GradientStop Color=\"#728f4a\" Offset=\"0.0\" /><GradientStop Color=\"#3c5f0c\" Offset=\"1.0\" /></LinearGradientBrush></Polygon.Fill></Polygon>"));
            Collection.Add(new HSLItem("GradientStop", "gradientstop~xaml~brush", "<GradientStop Color=\"#FFFFA028\" Offset=\"1\"/>"));
            Collection.Add(new HSLItem("ListBox", "listbox~xaml~control", "<ListBox x:Name=\"itemsControl\" Grid.Row=\"1\" ItemsSource=\"{Binding}\" ItemTemplate=\"{StaticResource MyDataTemplate}\" />"));
            Collection.Add(new HSLItem("MediaElement", "xaml~mediaelement~media~source~csharp", "<MediaElement Name=\"MediaElementElement\" Canvas.Left=\"0\" Canvas.Top=\"0\" Width=\"464\" Height=\"348\" IsMuted=\"False\" AutoPlay=\"True\" DownloadProgressChanged=\"MediaElement_DownloadProgressChanged\" MediaOpened=\"MediaPlayerElement_MediaOpened\" MediaEnded=\"MediaElement_MediaEnded\" MouseLeftButtonDown=\"MediaElement_MouseLeftButtonDown\" /> private void ThisMediaElement_DownloadProgressChanged(object sender, RoutedEventArgs e) private void ThisMediaElement_MarkerReached(object sender, TimelineMarkerRoutedEventArgs e) private void ThisMediaElement_MediaOpened(object sender, RoutedEventArgs e) private void ThisMediaElement_MarkerReached( object sender, TimelineMarkerRoutedEventArgs e) { string CurrentMarkerText = e.Marker.Text; string CurrentMarkerType = e.Marker.Type; int CurrentMarkerTimeInSeconds = e.Marker.Time.Seconds; }"));
            Collection.Add(new HSLItem("MediaSource", "mediasource~mediaelement~csharp~media", "ThisMediaElement.Source = new Uri(MediaSource, UriKind.RelativeOrAbsolute); ThisMediaElement.AutoPlay = true; ThisMediaElement.Play();"));
            Collection.Add(new HSLItem("MEF - Simple", "mef~microsoftextensibilityframework~csharp", "System.ComponentModel.Composition; System.ComponentModel.Composition.Initialization; // in some class : [Export(\"SomeValue\")] public string SomeValue = \"foobar\"; // in user app : [Import(\"SomeValue\")] public string SomeValue;// in constructor : CompositionInitializer.SatisfyImports(this);"));
            Collection.Add(new HSLItem("M-V-VM", "mvvm~xaml~designpattern", "// VIEW MODEL BASE CLASS : public class NardViewModelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; public void InvokePropertyChanged(string propertyName) { var e = new PropertyChangedEventArgs(propertyName); PropertyChangedEventHandler changed = PropertyChanged; if (changed != null) changed(this, e); } } // MODEL : public class AModelClass { public string SomeNardedValue { get set; } } // VIEW MODEL : public class AViewModelClass : NardViewModelBase { private AModelClass MyModel; public AViewModelClass() { MyModel = new AModelClass(); } public string SomeNardedValue { get { return MyModel.SomeNardedValue; } set { if (MyModel.SomeNardedValue != value) { MyModel.SomeNardedValue = value; InvokePropertyChanged(\"SomeNardedValue\"); } } }  } // VIEW : <UserControl x:Class=\"SilverlightMVVMNard.AViewClass\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:Nard=\"clr-namespace:SilverlightMVVMNard\"Width=\"400\" Height=\"300\"><UserControl.DataContext><Nard:AViewModelClass /></UserControl.DataContext><Grid x:Name=\"LayoutRoot\" Background=\"White\"><TextBox Text=\"{Binding SomeNardedValue, Mode=TwoWay}\" /></Grid></UserControl>"));
            Collection.Add(new HSLItem("Multi-Touch Basic's", "multitouch~multi-touch~xaml~canvas~csharp", "// IN THE XAML : <Canvas x:Name=\"Positions\" CacheMode=\"BitmapCache\" /> // IN THE CONSTRUCTOR :      Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); // TOUCH HANDLER : void Touch_FrameReported(object sender, TouchFrameEventArgs e) { foreach (TouchPoint tp in e.GetTouchPoints(Positions)) {  if (tp.Action == TouchAction.Down) { // DO SOMETHING : } else if (tp.Action == TouchAction.Up) { // DO SOMETHING ELSE : } else if (tp.Action == TouchAction.Move) { // OR DO SOMETHING MORE ELSE : } } }"));
            Collection.Add(new HSLItem("Object Tag", "html~objecttag~object", "<object data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100%\" height=\"100%\"><param name=\"source\" value=\"ClientBin/SUGWTKApp.xap\"/><param name=\"onerror\" value=\"onSilverlightError\" /><param name=\"background\" value=\"white\" /><param name=\"minRuntimeVersion\" value=\"3.0.40307.0\" /><param name=\"autoUpgrade\" value=\"true\" /><param name=\"SplashScreenSource\" value=\"Inc/Preloader.xaml\" />  <param name=\"MainRSSFeed\" value=\"http://www.hackingsilverlight.net/twitter.asp\" />  <br />&nbsp;<br /></object>"));
            Collection.Add(new HSLItem("OOB - HyperLink", "oobhyperlink~oob~link~hack~openwindow~csharp~myhyperlink~uri~hyperlinkbutton~button", "public class MyHyperLink : HyperlinkButton   { public MyHyperLink(string navigateUri) {   base.NavigateUri = new Uri(navigateUri);   TargetName = \"_blank\";   base.OnClick();   } }"));
            Collection.Add(new HSLItem("OpacityMask", "opacitymask~xaml~canvas", "<Canvas.OpacityMask><LinearGradientBrush><GradientStop Offset=\"0.05\" Color=\"#00000000\"/><GradientStop Offset=\"1\" Color=\"#FF3c5f0c\"/></LinearGradientBrush></Canvas.OpacityMask>"));
            Collection.Add(new HSLItem("Open File Dialog", "openfiledialog~control~csharp", "OpenFileDialog OpenFileDialog1 = new OpenFileDialog(); OpenFileDialog1.Title = \"Open Image File\"; OpenFileDialog1.Filter = \"WMV|*.wmv\"; if (OpenFileDialog1.ShowDialog() == DialogResult.OK) { foreach (FileDialogFileInfo fileInfo in OpenFileDialog1.SelectedFiles) { System.IO.Stream s = fileInfo.OpenRead(); MyMediaElement.SetSource(s); } }"));
            Collection.Add(new HSLItem("Open Window in Browser", "open~window~openwindow~dombridge~csharp~url~uri", "System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(ThisURI), \"_blank\");"));
            Collection.Add(new HSLItem("Out of Browser Settings XML", "oob~xml~outofbrowsersettings~outofbrowser", "<OutOfBrowserSettings ShortName=\"HackingSilverlightBrowser Application\" EnableGPUAcceleration=\"False\" ShowInstallMenuItem=\"True\"><OutOfBrowserSettings.Blurb>HackingSilverlightBrowser Application on your desktop; at home, at work or on the go.</OutOfBrowserSettings.Blurb><OutOfBrowserSettings.WindowSettings><WindowSettings Title=\"HackingSilverlightBrowser Application\" /></OutOfBrowserSettings.WindowSettings><OutOfBrowserSettings.Icons><Icon Size=\"128,128\">Resources/128.png</Icon></OutOfBrowserSettings.Icons></OutOfBrowserSettings>"));
            Collection.Add(new HSLItem("Out of Browser Is Installed", "oob~outofbrowser~isinstalled~csharp", "if (Application.Current.InstallState == InstallState.Installed) { installbutton.Visibility = Visibility.Collapsed; }"));
            Collection.Add(new HSLItem("Out of Browser To Install", "oob~outofbrowser~install~csharp", "Application.Current.Install();"));
            Collection.Add(new HSLItem("Panel - Custom", "panel~custom~control~layout~customcontrol", "public class LamePanel : Panel { protected override Size MeasureOverride(Size availableSize) { for (int x = 0; x < this.Children.Count; x++) { this.Children[x].Measure(new Size( double.PositiveInfinity, double.PositiveInfinity)); } return new Size(); } protected override Size ArrangeOverride(Size FinalSize) { double Top = 0; double Left = 0; double Width = 0; double Height = 0; double NextTop = 0; foreach (UIElement element in this.Children) { Width = element.DesiredSize.Width; Height = element.DesiredSize.Height; if ((Left + Width) > FinalSize.Width) { Left = 0; Top = NextTop; NextTop = 0; }  element.Arrange(new Rect(Left, Top, Width, Height)); Left = Left + Width; NextTop = Math.Max(NextTop, Top + Height);  }  return FinalSize; } }"));
            Collection.Add(new HSLItem("Password", "xaml~password~control", "<PasswordBox x:Name=\"UserPassword\" Height=\"24\" Width=\"165\" Margin=\"0,0,0,0\" FontSize=\"10\" Grid.Row=\"3\"/>"));
            Collection.Add(new HSLItem("Path", "xaml~path~shape", "<Path Name=\"PathElement\" Data=\"M 10, 10 H 150 V 150 C 155,155 160,160 140,165 A 50, 50 200 1 0 100,100 L 10, 10\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" Fill=\"#728f4a\"/>"));
            Collection.Add(new HSLItem("PixelShader", "xaml~pixelshader~image~effect~bitmapeffect", "<Image.Effect><DropShadowEffect BlurRadius=\"5\" ShadowDepth=\"5\" Opacity=\"0.1\" /></Image.Effect><BlurEffect Radius=\"5\" /><hsl:Shader x:Name=\"TargetShader\" SetEffect=\"Ripples\" />"));
            Collection.Add(new HSLItem("Plane Projection", "planeprojection~xaml~image~transform", "<Image.Projection><PlaneProjection RotationY=\"45\" RotationX=\"45\" /></Image.Projection>"));
            Collection.Add(new HSLItem("PointAnimation", "pointanimation~xaml~animation", "<PointAnimation Storyboard.TargetName=\"PathElementPart3\" Storyboard.TargetProperty=\"Point1\" From=\"100,100\" To=\"150,150\" Duration=\"0:0:5\" />"));
            Collection.Add(new HSLItem("PointAnimationUsingKeyFrames", "pointanimationusingkeyframes~xaml~animation", "<PointAnimationUsingKeyFrames BeginTime=\"00:00:00\" Storyboard.TargetName=\"path\" Storyboard.TargetProperty=\"(Path.Data).(PathGeometry.Figures)[0].(PathFigure.StartPoint)\"><SplinePointKeyFrame KeyTime=\"00:00:01\" Value=\"49.6943445028898,202.354000518664\"/><SplinePointKeyFrame KeyTime=\"00:00:02\" Value=\"107.371594649822,194.363627915801\" /></PointAnimationUsingKeyFrames>"));
            Collection.Add(new HSLItem("Polyline", "xaml~polyline~shape", "<Polyline Name=\"LineElement\" Points=\"10,10 150,150 150,25\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" />"));
            Collection.Add(new HSLItem("Polygon", "polygon~xaml~shape", "<Polygon Name=\"PolygonElement\" Points=\"10,10 150,150 150,25\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\"  Fill=\"#728f4a\" />"));
            Collection.Add(new HSLItem("Preloader", "html~object~preloader~xaml", "<Grid xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"     xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" ></Grid> // HTML : <object id=\"SilverlightControlObj\" name=\"SilverlightControlObjNm\" data=\"data:application/x-silverlight-2,\" type=\"application/x-silverlight-2\" width=\"100%\" height=\"100%\" ><param name=\"SplashScreenSource\" value=\"Inc/Preloader.xaml\" />  "));
            Collection.Add(new HSLItem("RadialGradientBrush", "radialgradientbrush~brush~xaml", "<Polygon Name=\"PolygonElement\" Points=\"10,10 150,150 150,25\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\"><Polygon.Fill><RadialGradientBrush GradientOrigin=\"0,1\"><GradientStop Color=\"#728f4a\" Offset=\"0.0\"/><GradientStop Color=\"#3c5f0c\" Offset=\"1.0\"/></RadialGradientBrush></Polygon.Fill></Polygon>"));
            Collection.Add(new HSLItem("RadioButton", "radiobutton~xaml~control", "<RadioButton x:Name=\"Radio1\" GroupName=\"RadioSet\" Checked=\"Radio1_Checked\" Click=\"Radio1_Click\" ToolTip=\"radio my radio\" Grid.Column=\"1\" />"));
            Collection.Add(new HSLItem("Random Number", "randomnumber~csharp~int", "private int RandomNumber(int min, int max) {  Random random = new Random(); return random.Next(min, max); }"));
            Collection.Add(new HSLItem("Read String Resource", "string~csharp~readstringresource~resource~resourcefile~readstringresourcefile", "public static string ReadStringResource(string ResourcePath){StreamResourceInfo FileHandle = Application.GetResourceStream(new Uri(ResourcePath, UriKind.RelativeOrAbsolute));TextReader MyReader = new StreamReader(FileHandle.Stream);return MyReader.ReadToEnd();}"));
            Collection.Add(new HSLItem("Rectangle", "rectangle~xaml~shape", "<Rectangle Name=\"RectangleElement\" Height=\"100\" Width=\"100\" Canvas.Left=\"50\" Canvas.Top=\"50\" RadiusX=\"10\" RadiusY=\"10\" Fill=\"#728f4a\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" />"));
            Collection.Add(new HSLItem("RenderTransform", "rendertransform~xaml~transform", "<Polygon.RenderTransform><TransformGroup><RotateTransform Angle=\"10\" /><SkewTransform AngleX=\"10\" /><ScaleTransform ScaleX=\"1.3\" ScaleY=\".7\" /></TransformGroup></Polygon.RenderTransform>"));
            Collection.Add(new HSLItem("Resource Dictrionary", "generic.xaml~resourcedictionary~xaml~dialcontrol~template~setter", "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:vsm=\"clr-namespace:System.Windows;assembly=System.Windows\" xmlns:hsl=\"clr-namespace:HackingSilverlightLibrary\" > <Style TargetType=\"hsl:Dial\"><Setter Property=\"Template\"><Setter.Value><ControlTemplate TargetType=\"hsl:Dial\"><Grid x:Name=\"Knob\" Background=\"Transparent\" ><ContentPresenter x:Name=\"Background\" Content=\"{TemplateBinding KnobBackground}\"/><ContentPresenter x:Name=\"DialKnob\" Content=\"{TemplateBinding KnobFace}\" RenderTransformOrigin=\"0.483,0.479\" ><ContentPresenter.RenderTransform><TransformGroup><RotateTransform x:Name=\"DialAngle\" Angle=\"0\" /></TransformGroup></ContentPresenter.RenderTransform></ContentPresenter></Grid></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>"));
            Collection.Add(new HSLItem("Root URL", "rooturl~csharp~uri~url", "if (Source.IndexOf(\"http\") < 0) { string URL = System.Windows.Browser.HtmlPage.Document.DocumentUri.AbsoluteUri; Source = URL.Substring(0, URL.LastIndexOf('/')) + \"/\" + Source.Replace('\\', '/');}"));
            Collection.Add(new HSLItem("RotateTransform", "rotatetransform~xaml~transform", "<RotateTransform Angle=\"-42.522\" CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/>"));
            Collection.Add(new HSLItem("RowDefinition", "rowdefinition~grid~xaml", "<RowDefinition Height=\"*\"></RowDefinition>"));
            Collection.Add(new HSLItem("ScaleTransform", "xaml~scaletransform~transform", "<ScaleTransform CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/>"));
            Collection.Add(new HSLItem("Screen Size", "screensize~csharp", "Application.Current.Host.Content.ActualWidth; Application.Current.Host.Content.ActualHeight;"));
            Collection.Add(new HSLItem("Setter", "setter~xaml~templates~resource~template", "<Setter Property=\"Background\"><Setter.Value><RadialGradientBrush GradientOrigin=\"0,1\"><GradientStop Color=\"#728f4a\" Offset=\"0.0\"/><GradientStop Color=\"#3c5f0c\" Offset=\"1.0\"/></RadialGradientBrush></Setter.Value></Setter> "));
            Collection.Add(new HSLItem("SkewTransform", "skewtransform~xaml~transform", "<SkewTransform CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/> "));
            Collection.Add(new HSLItem("SplineDoubleKeyFrame Animation", "splinedoublekeyframe~xaml~animation", "<SplineDoubleKeyFrame KeyTime=\"00:00:01\" Value=\"1.06\"/>"));
            Collection.Add(new HSLItem("Polygon", "polygon~xaml", "<Polygon Name=\"PolygonElement\" Points=\"10,10 150,150 150,25\" Stroke=\"#3c5f0c\" StrokeThickness=\"3\" ><Polygon.Fill><SolidColorBrush Color=\"#728f4a\" /></Polygon.Fill></Polygon>"));
            Collection.Add(new HSLItem("Stackpanel", "stackpanel~xaml~rectangle~control", "<StackPanel Width=\"200\" Height=\"200\" Orientation=\"Vertical\" Background=\"Gray\"><Rectangle Width=\"50\" Height=\"50\" Fill=\"Green\"></Rectangle><Rectangle Width=\"50\" Height=\"50\" Fill=\"Blue\"></Rectangle></StackPanel>"));
            Collection.Add(new HSLItem("Storyboard", "doubleanimation~animation~storyboard~panel", "<Storyboard x:Name=\"PositionPlayBack\" Storyboard.TargetName=\"TBStatusBarPlayProgress\" ><DoubleAnimation x:Name=\"PositionPlayBackWidth\" Storyboard.TargetProperty=\"Width\" To=\"0\" Duration=\"0:0:.1\" /><DoubleAnimation x:Name=\"PositionIconLeft\" Storyboard.TargetName=\"ScrubIcon\" Storyboard.TargetProperty=\"(Canvas.Left)\" To=\"0\" Duration=\"0:0:.1\" /></Storyboard>"));
            Collection.Add(new HSLItem("TextBlock", "textblock~xaml~control~text~font", "<TextBlock Name=\"FirstSilverlightText\" FontSize=\"15\" FontWeight=\"Thin\" FontStyle=\"Italic\" FontStretch=\"Condensed\" FontFamily=\"Verdana\"TextChanged=\"TextBox_TextChanged\" GotFocus=\"TextBox_GotFocus\"LostFocus=\" TextBox_LostFocus\" >Hello World<TextBlock.Foreground ><RadialGradientBrush GradientOrigin=\"0,1\"><GradientStop Color=\"#728f4a\" Offset=\"0.0\"/><GradientStop Color=\"#3c5f0c\" Offset=\"1.0\"/></RadialGradientBrush></TextBlock.Foreground></TextBlock>"));
            Collection.Add(new HSLItem("ToggleButton", "togglebutton~xaml~control", "<ToggleButton x:Name=\"MyFirstToggleButton\" Click=\"MyButton_Click\" ToolTip=\"My first tool tip\" Content=\"click me\" />"));
            Collection.Add(new HSLItem("TransformGroup", "xaml~transformgroup~transform", "<TransformGroup><ScaleTransform CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/><SkewTransform CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/><RotateTransform Angle=\"-42.522\" CenterX=\"0.090000003576278687\" CenterY=\"0.925000011920929\"/><TranslateTransform X=\"4\" Y=\"45\" /></TransformGroup> "));
            Collection.Add(new HSLItem("TranslateTransform", "translatetransform~xaml~transform", "<TranslateTransform X=\"11\" Y=\"8\" /> "));
            Collection.Add(new HSLItem("Trigger", "routedevent~canvas~trigger~xaml~eventtrigger", "<Canvas.Triggers><EventTrigger RoutedEvent=\"Canvas.Loaded\"><EventTrigger.Actions><BeginStoryboard><Storyboard>...</Storyboard></BeginStoryboard></EventTrigger.Actions></EventTrigger></Canvas.Triggers>"));
            Collection.Add(new HSLItem("UserControl", "xaml~usercontrol~control", "<UserControl x:Class=\"SilverlightApplication1.Page\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:HSL=\"clr-namespace:HackingSilverlightLibrary;assembly=HackingSilverlightLibrary\" Width=\"400\" Height=\"300\">"));
            Collection.Add(new HSLItem("Unzipper Customer Control", "zip~unzip~xap~unzipper~csharp~customcontrol~control", "public class UnZipper{// based on http://www.sharpgis.net/post/2009/04/21/REALLY-small-unzip-utility-for-Silverlight.aspx : private Stream stream;public UnZipper(Stream zipFileStream){ this.stream = zipFileStream; }public Stream GetFileStream(string filename){ Uri fileUri = new Uri(filename, UriKind.Relative); StreamResourceInfo info = new StreamResourceInfo(this.stream, null); StreamResourceInfo stream = System.Windows.Application.GetResourceStream(info, fileUri);if (stream != null){return stream.Stream;}return null; }public IEnumerable<string> GetFileNamesInZip(){ BinaryReader reader = new BinaryReader(stream); stream.Seek(0, SeekOrigin.Begin); string name = null;while (ParseFileHeader(reader, out name)){ yield return name; } }private static bool ParseFileHeader(BinaryReader reader, out string filename){ filename = null;if (reader.BaseStream.Position < reader.BaseStream.Length){ int headerSignature = reader.ReadInt32();if (headerSignature == 67324752) // PKZIP : { reader.BaseStream.Seek(14, SeekOrigin.Current); // ignore unneeded values : int compressedSize = reader.ReadInt32(); int unCompressedSize = reader.ReadInt32(); short fileNameLenght = reader.ReadInt16(); short extraFieldLenght = reader.ReadInt16();filename = new string(reader.ReadChars(fileNameLenght));if (string.IsNullOrEmpty(filename)){return false;}// Seek to the next file header : reader.BaseStream.Seek(extraFieldLenght + compressedSize, SeekOrigin.Current);if (unCompressedSize == 0) // Directory or not supported. Skip it : {return ParseFileHeader(reader, out filename);}else{return true;}}}return false;}}"));
            Collection.Add(new HSLItem("WebClient", "webclient~csharp~control", "WebClient client = new WebClient(); client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadCompleted); client.DownloadStringAsync(new Uri(\"http://someurl\")); void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e) { try { if (!string.IsNullOrEmpty(e.Result)) {  // DO SOMETHING ... : } } catch (Exception) { } } "));
            Collection.Add(new HSLItem("VideoBrush", "videobrush~xaml~textblock~source~mediaelement~media", "<TextBlock.Foreground><VideoBrush SourceName=\"MediaElementElement\" /></TextBlock.Foreground>"));
            Collection.Add(new HSLItem("ViewPanel3D Custom Control", "viewpanel3d~panel~csharp~customcontrol~control", "public class ViewPanel3D : Panel { Dictionary<UIElement, Transform> _originalTransforms = new Dictionary<UIElement, Transform>();public static readonly DependencyProperty ClientXProperty = DependencyProperty.RegisterAttached(\"ClientX\", typeof(double), typeof(ViewPanel3D), null);public static readonly DependencyProperty ClientYProperty = DependencyProperty.RegisterAttached(\"ClientY\", typeof(double), typeof(ViewPanel3D), null);public static readonly DependencyProperty ClientZProperty = DependencyProperty.RegisterAttached(\"ClientZ\", typeof(int), typeof(ViewPanel3D), null);public static readonly DependencyProperty YProperty = DependencyProperty.Register(\"Y\", typeof(double), typeof(ViewPanel3D), new PropertyMetadata(new PropertyChangedCallback(OnCameraPositionChanged)));public static readonly DependencyProperty ZProperty = DependencyProperty.Register(\"Z\", typeof(double), typeof(ViewPanel3D), new PropertyMetadata(new PropertyChangedCallback(OnCameraPositionChanged)));public static readonly DependencyProperty XProperty = DependencyProperty.Register(\"X\", typeof(double), typeof(ViewPanel3D), new PropertyMetadata(new PropertyChangedCallback(OnCameraPositionChanged)));public static double GetClientX(DependencyObject DepObj) { return (double)DepObj.GetValue(ClientXProperty); } public static void SetClientX(DependencyObject DepObj, double Value) { DepObj.SetValue(ClientXProperty, Value); } public static double GetClientY(DependencyObject DepObj) { return (double)DepObj.GetValue(ClientYProperty); } public static void SetClientY(DependencyObject DepObj, double Value) { DepObj.SetValue(ClientYProperty, Value); } public static int GetClientZ(DependencyObject DepObj) { return (int)DepObj.GetValue(ClientZProperty); } public static void SetClientZ(DependencyObject DepObj, int Value) { DepObj.SetValue(ClientZProperty, Value); } public double X { get  {  return (double)GetValue(XProperty);  } set  {  SetValue(XProperty, value);  }  } public double Y { get  {  return (double)GetValue(YProperty);  } set  {  SetValue(YProperty, value);  }  } public double Z { get  {  return (double)GetValue(ZProperty);  } set  {  SetValue(ZProperty, value);  }  } protected override Size MeasureOverride(Size constraint) { Size unconstrained = new Size(double.PositiveInfinity, double.PositiveInfinity);foreach (UIElement child in Children) { if (child != null) { child.Measure(unconstrained); }  } return new Size(); } protected override Size ArrangeOverride(Size FinalSize) { foreach (UIElement Child in Children) { Point ThisPosition = new Point();if (Child == null) continue;double NewLeft = GetClientX(Child) - X;double NewTop = GetClientY(Child) - Y;int Depth = GetClientZ(Child);if (!_originalTransforms.ContainsKey(Child)) { _originalTransforms.Add(Child, Child.RenderTransform); } if (Depth < Z) { MatrixTransform NewTransfrom = new MatrixTransform();double ZDifferential = 300.0 / (300.0 + Math.Abs(Z - Depth));double scaleFactor = 300.0 / Math.Abs(Z - Depth);ThisPosition.X = (FinalSize.Width / 2) - (Child.DesiredSize.Width / 2) + (NewLeft * ZDifferential);ThisPosition.Y = (FinalSize.Height / 2) - (Child.DesiredSize.Height / 2) - (NewTop * ZDifferential);Child.SetValue(Canvas.ZIndexProperty, Depth);Child.RenderTransformOrigin = new Point(0.5, 0.5);MatrixTransform NewMatrixTransform = GetMatrixtransform(_originalTransforms[Child]);Matrix ThisMatrix = NewMatrixTransform.Matrix;ThisMatrix.M11 = scaleFactor;ThisMatrix.M22 = scaleFactor;NewTransfrom.Matrix = ThisMatrix;Child.RenderTransform = NewTransfrom;Child.Arrange(new Rect(ThisPosition, new Point(ThisPosition.X + Child.DesiredSize.Width, ThisPosition.Y + Child.DesiredSize.Height))); } else { ScaleTransform ThisScaleTransform = new ScaleTransform();ThisScaleTransform.ScaleX = 0;ThisScaleTransform.ScaleY = 0;Child.RenderTransform = ThisScaleTransform; }  } return FinalSize; } private MatrixTransform GetMatrixtransform(Transform InputTransform) { MatrixTransform ReturnTransform = new MatrixTransform();switch (InputTransform.GetType().ToString()) { case \"System.Windows.Media.ScaleTransform\":ScaleTransform ThisTransform = InputTransform as ScaleTransform;ReturnTransform.Matrix = new Matrix(ThisTransform.ScaleX, 0, 0, ThisTransform.ScaleY, 0, 0);break;case \"System.Windows.Media.RotateTransform\":double ThisAngle = (InputTransform as RotateTransform).Angle * Math.PI / 180.0;ReturnTransform.Matrix = new Matrix(Math.Cos(ThisAngle), Math.Sin(ThisAngle), -Math.Sin(ThisAngle), Math.Cos(ThisAngle), 0, 0);break;case \"System.Windows.Media.TranslateTransform\":TranslateTransform ThisTransform2 = InputTransform as TranslateTransform;ReturnTransform.Matrix = new Matrix(0, 0, 0, 0, ThisTransform2.X, ThisTransform2.Y);break;case \"System.Windows.Media.MatrixTransform\":ReturnTransform = InputTransform as MatrixTransform;break;case \"System.Windows.Media.TransformGroup\":TransformGroup ThisTransform3 = InputTransform as TransformGroup;Matrix NewMatrix = Matrix.Identity;for (int i = 0; i < ThisTransform3.Children.Count; i++) { Matrix ThisMatrix = GetMatrixtransform(ThisTransform3.Children[i]).Matrix;NewMatrix = new Matrix(NewMatrix.M11 * ThisMatrix.M11 + NewMatrix.M12 * ThisMatrix.M21, NewMatrix.M11 * ThisMatrix.M12 + NewMatrix.M12 * ThisMatrix.M22, NewMatrix.M21 * ThisMatrix.M11 + NewMatrix.M22 * ThisMatrix.M21, NewMatrix.M21 * ThisMatrix.M12 + NewMatrix.M22 * ThisMatrix.M22, NewMatrix.OffsetX * ThisMatrix.M11 + NewMatrix.OffsetY * ThisMatrix.M21 + ThisMatrix.OffsetX, NewMatrix.OffsetX * ThisMatrix.M12 + NewMatrix.OffsetY * ThisMatrix.M22 + ThisMatrix.OffsetY); } ReturnTransform.Matrix = NewMatrix;break;default:ReturnTransform.Matrix = Matrix.Identity;break; } return ReturnTransform; } static void OnCameraPositionChanged(DependencyObject DepObj, DependencyPropertyChangedEventArgs e) { (DepObj as ViewPanel3D).InvalidateArrange(); } public void SetViewPort(double InputX, double InputY) { X = -1 * (InputX - (this.ActualWidth / 2));Y = InputY - (this.ActualHeight / 2); }  }"));
            //Collection.Add(new HSLItem("", "", "")); 
        } 
    }
}
